﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GUI
{
    public partial class FrmKunde : Form
    {
        private int tilstand;


        private const int STARTTILSTAND = 1;
        private const int OPRETTILSTAND = 2;
        private const int REDIGERTILSTAND = 3;
        private const int SLETTILSTAND = 4;

        public FrmKunde()
        {
            InitializeComponent();
        }

        private void starttilstand()
        {
            tilstand = STARTTILSTAND;

            //Knapper
            btnOpretKunde1.Enabled = true;
            btnRedigerKunde1.Enabled = true;
            btnSletKunde1.Enabled = true;

            btnOpretKunde2.Enabled = false;
            btnRedigerKunde2.Enabled = false;
            btnSletKunde2.Enabled = false;

            btnOpretKunde2.Hide();
            btnRedigerKunde2.Hide();
            btnSletKunde2.Hide();


            //Tekst-bokse
            txtNavn.Enabled = false;
            txtGade.Enabled = false;
            txtPostNr.Enabled = false;
            txtTlf.Enabled = false;
            txtMobil.Enabled = false;

            //Combo-bokse
            cboKundeNr.Enabled = false;
        }

        private void oprettilstand()
        {
            tilstand = OPRETTILSTAND;

            //Knapper
            btnOpretKunde1.Enabled = true;
            btnRedigerKunde1.Enabled = false;
            btnSletKunde1.Enabled = false;

            btnOpretKunde2.Enabled = true;
            btnRedigerKunde2.Enabled = false;
            btnSletKunde2.Enabled = false;

            btnOpretKunde2.Show();
            btnRedigerKunde2.Hide();
            btnSletKunde2.Hide();


            //Tekst-bokse
            txtNavn.Enabled = true;
            txtGade.Enabled = true;
            txtPostNr.Enabled = true;
            txtTlf.Enabled = true;
            txtMobil.Enabled = true;


            //Combo-bokse
            cboKundeNr.Enabled = false;
        }

        private void redigertilstand()
        {
            tilstand = REDIGERTILSTAND;

            //Knapper
            btnOpretKunde1.Enabled = false;
            btnRedigerKunde1.Enabled = true;
            btnSletKunde1.Enabled = false;

            btnOpretKunde2.Enabled = false;
            btnRedigerKunde2.Enabled = true;
            btnSletKunde2.Enabled = false;

            btnOpretKunde2.Hide();
            btnRedigerKunde2.Show();
            btnSletKunde2.Hide();


            //Tekst-bokse
            txtNavn.Enabled = true;
            txtGade.Enabled = true;
            txtPostNr.Enabled = true;
            txtTlf.Enabled = true;
            txtMobil.Enabled = true;


            //Combo-bokse
            cboKundeNr.Enabled = true;
        }

        private void slettilstand()
        {
            tilstand = SLETTILSTAND;

            //Knapper
            btnOpretKunde1.Enabled = false;
            btnRedigerKunde1.Enabled = false;
            btnSletKunde1.Enabled = true;

            btnOpretKunde2.Enabled = false;
            btnRedigerKunde2.Enabled = false;
            btnSletKunde2.Enabled = true;

            btnOpretKunde2.Hide();
            btnRedigerKunde2.Hide();
            btnSletKunde2.Show();


            //Tekst-bokse
            txtNavn.Enabled = false;
            txtGade.Enabled = false;
            txtPostNr.Enabled = false;
            txtTlf.Enabled = false;
            txtMobil.Enabled = false;


            //Combo-bokse
            cboKundeNr.Enabled = true;
        }

        private void FrmKunde_Load(object sender, EventArgs e)
        {
            starttilstand();
        }

        private void btnOpretKunde1_Click(object sender, EventArgs e)
        {
            oprettilstand();
        }

        private void btnRedigerKunde1_Click(object sender, EventArgs e)
        {
            redigertilstand();
        }

        private void btnSletKunde1_Click(object sender, EventArgs e)
        {
            slettilstand();
        }

        private void btnRedigerKunde2_Click(object sender, EventArgs e)
        {
            starttilstand();
        }

        private void btnOpretKunde2_Click(object sender, EventArgs e)
        {
            starttilstand();
        }

        private void btnSletKunde2_Click(object sender, EventArgs e)
        {
            starttilstand();
        }
    }
}
